<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 14-10-28
 * Time: 上午9:32
 * @author 郑钟良<zzl@ourstu.com>
 */

namespace Question\Widget;

use Think\Action;

class QuestionPartWidget extends Action
{
    public function partQuestion($question_id=0,$need_answer=0){
        if($question_id){
            $question=D('Question/Question')->getQuestion($question_id);
            $this->assign('question',$question);
            $this->assign('need_answer',$need_answer);
            if($need_answer){
                $map['uid']=$question['uid'];
                $map['question_id']=$question['id'];
                $answer=D('Question/QuestionAnswer')->getAnswerList($map,1,$totalCount);
                $answer=$answer[0];
                $totalCount=$totalCount-1;
                $this->assign('answer',$answer);
                $have_more=$totalCount?1:0;
                $this->assign('have_more',$have_more);
            }
            $this->display(T('Question@Widget/question_part'));
        }
        return false;
    }
} 